package com.songlanyun.modules.coupon.controller.admin;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.songlanyun.modules.coupon.entity.CouponGoodsEntity;
import com.songlanyun.modules.coupon.service.CouponGoodsService;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;



/**
 * 优惠券与商品的关系
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2022-07-05 15:20:02
 */
@RestController
@RequestMapping("coupon/coupongoods")
public class CouponGoodsController {
    @Autowired
    private CouponGoodsService couponGoodsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("coupon:coupongoods:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = couponGoodsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("coupon:coupongoods:info")
    public R info(@PathVariable("id") Long id){
		CouponGoodsEntity couponGoods = couponGoodsService.getById(id);

        return R.ok().put("couponGoods", couponGoods);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("coupon:coupongoods:save")
    public R save(@RequestBody CouponGoodsEntity couponGoods){
		couponGoodsService.save(couponGoods);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("coupon:coupongoods:update")
    public R update(@RequestBody CouponGoodsEntity couponGoods){
		couponGoodsService.updateById(couponGoods);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("coupon:coupongoods:delete")
    public R delete(@RequestBody Long[] ids){
		couponGoodsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
